package com.servicesDirectory.action.organisation.directorate;

import java.util.List;

import javax.swing.JOptionPane;

import com.opensymphony.xwork2.ActionSupport;
import com.servicesDirectory.bo.organisation.directorate.DirectorateBOImpl;
import com.servicesDirectory.common.vo.organisation.DirectorateVO;

/**
 * @author TuMC6B
 * 
 */
public class DirectorateAction extends ActionSupport {

	public int directorateID;
	String tab = "tab6";
	String filter = "";
	boolean checkInclude;
	public List<DirectorateVO> directorateList;
	DirectorateBOImpl bo;
	private static final long serialVersionUID = 1L;
	public DirectorateVO directorateVO = new DirectorateVO();

	public String getTab() {
		return tab;
	}

	public void setTab(String tab) {
		this.tab = tab;
	}

	public String getFilter() {
		return filter;
	}

	public void setFilter(String filter) {
		this.filter = filter;
	}

	
	public boolean isCheckInclude() {
		return checkInclude;
	}

	public void setCheckInclude(boolean checkInclude) {
		this.checkInclude = checkInclude;
	}

	public List<DirectorateVO> getDirectorateList() {
		return directorateList;
	}

	public void setDirectorateList(List<DirectorateVO> directorateList) {
		this.directorateList = directorateList;
	}

	public DirectorateBOImpl getBo() {
		return bo;
	}

	public void setBo(DirectorateBOImpl bo) {
		this.bo = bo;
	}


	public int getDirectorateID() {
		return directorateID;
	}

	public void setDirectorateID(int directorateID) {
		this.directorateID = directorateID;
	}

	@Override
	public String execute() {
		JOptionPane.showMessageDialog(null, "execute");

		return SUCCESS;
	}

	public String listDirectorate() {
		
		DirectorateBOImpl bo = new DirectorateBOImpl();
		this.directorateList = bo.list(filter, checkInclude);
		return SUCCESS;

	}

	public String insert() {
		bo = new DirectorateBOImpl();
		String result = bo.insert(directorateVO) ? "success" : "error";
		return result;
	}
	public String update(){
		bo = new DirectorateBOImpl();
		String result = bo.update(directorateVO)?"success":"error";
		return result;
	}
	public String fetch(){
		bo = new DirectorateBOImpl();
		directorateList = bo.search(directorateID);
		return "UPDATE";
	}

	@Override
	public void validate() {
	}

	public DirectorateVO getDirectorateVO() {
		return directorateVO;
	}

	public void setDirectorateVO(DirectorateVO directorateVO) {
		this.directorateVO = directorateVO;
	}

}